Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add display, descriptionWidth, textWrap and isInvalid props to EuiExpression #3467

Merged
merged 33 commits into from
Jun 2, 2020

Conversation

andreadelrio
Copy link
Contributor

@andreadelrio andreadelrio commented May 12, 2020

Summary

This PR adds the display, descriptionWidth, textWrap and isInvalid props to EuiExpression. The improvements introduced in this PR come, in part, as response to this Kibana ticket.

There are three new sections in the docs. One where display and descriptionWidth are shown and two others for textWrap and isInvalid respectively.

New: Column display
indicies

New: Invalid state for both clickable and read-only Expressions
image

New: Text truncation
image

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation examples
  • Added or updated jest tests
    - [ ] Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

@andreadelrio andreadelrio force-pushed the expression-truncate branch from 06dd882 to 4adbc16 Compare May 13, 2020 02:26
@andreadelrio andreadelrio force-pushed the expression-truncate branch from 4adbc16 to 23dad35 Compare May 13, 2020 02:51
@andreadelrio andreadelrio changed the title Add truncation to EuiExpression Add truncate prop to EuiExpression May 13, 2020
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

@andreadelrio andreadelrio marked this pull request as ready for review May 13, 2020 04:51
@andreadelrio andreadelrio requested review from cchaos and mdefazio May 13, 2020 04:52
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

@mdefazio
Copy link
Contributor

This looks good. The demo example wasn't showing the truncate prop however. And do we need a min-width? Perhaps just enough so 2 letter operators still show?

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This thing is finally getting used and getting some ❤️ love.

src/components/expression/expression.tsx Outdated Show resolved Hide resolved
src/components/expression/_expression.scss Outdated Show resolved Hide resolved
src-docs/src/views/expression/truncate.tsx Outdated Show resolved Hide resolved
@andreadelrio andreadelrio changed the title Add truncate prop to EuiExpression Add textWrap prop to EuiExpression May 13, 2020
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

@andreadelrio
Copy link
Contributor Author

This looks good. The demo example wasn't showing the truncate prop however. And do we need a min-width? Perhaps just enough so 2 letter operators still show?

@mdefazio not sure what you mean by this, can you elaborate? do you mean a min-width for the description (left side) or for EuiExpression as a whole?

@andreadelrio
Copy link
Contributor Author

@cchaos wondering if it's wrong having to set a width on EuiExpression in order to have truncation work?

@andreadelrio andreadelrio requested a review from cchaos May 13, 2020 23:44
@mdefazio
Copy link
Contributor

do you mean a min-width for the description (left side) or for EuiExpression as a whole?

I meant originally for the description (left-side), however maybe it should be as a whole—not sure which is right though tbh.

Some thoughts as I play around with this some more:

  1. Should we allow the expressions to wrap as the container shrinks (assuming the expression itself can still fit on one line)?

  2. If the expression can't fit on one line, then we truncate it.

  3. Does it become tricky then if a 2nd expression is added dynamically based on the choice of the first? Do we want this to stay on the same line? Or simply allow it to drop to a new one? I know in my original mock I showed it on the same line, but I understand this presents some issues. Perhaps in this scenario, both expressions are treated as one whole so we can truncate the only the end of it without the 2nd expression breaking to a new line. Not sure if this is possible though, or doesn't just create more trouble than good.
    image

  4. If these are true, then I'm guessing we would need the tooltip on every element, since we wouldn't know when it gets truncated?

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

@andreadelrio
Copy link
Contributor Author

There also still seems to be a bit of a truncation issue. It might still be nice for consumers to be able to adjust this with a simple prop. Similar to how EuiCodeEditor handles whiteSpace you do for `wordWrap: 'truncate' | 'breakWord'.

Screen Shot 2020-05-29 at 17 20 10 PM

@cchaos do you think that truncation should be for both the description and the value? or just the value? I would think that just for the value.

image

And another doubt, what do you think the truncate behaviour should be on the second Expression here ^? Truncate so that it only takes up one line? Like this
image

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

@cchaos
Copy link
Contributor

cchaos commented Jun 1, 2020

I would assume you'd truncate both if they got so wide that they extended the full width of the container. If this isn't exactly how the consumer wants the behavior, they can add custom wrappers to their own implementation.
Image 2020-06-01 at 11 32 51 AM

But I think it's more obvious what the component will do unless you specify a different wrap/truncation prop for each part (but we shouldn't need to go down that route).

@andreadelrio
Copy link
Contributor Author

@cchaos I added the textWrap prop and added a new example for it.

image

@andreadelrio andreadelrio changed the title Add display, descriptionWidth and isInvalid props to EuiExpression Add display, descriptionWidth, textWrap and isInvalid props to EuiExpression Jun 1, 2020
@andreadelrio
Copy link
Contributor Author

@cchaos @mdefazio this should be ready for review. Can't re-request so pinging you this way. Thanks

@andreadelrio andreadelrio force-pushed the expression-truncate branch from 4590e7a to d15a4b4 Compare June 1, 2020 18:21
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good. It maintains the original ideals of the component while simply making it more robust with more alternate displays. It might be a good idea to update the PR summary screenshots.

One addition to the truncate prop we may want to consider is using EuiInnerText to apply the rendered text as the title prop to both the description and values. This will ensure that the full truncated text can be seen with a long mouse hover.

Most of my other comments are copy changes and best practices. But truly this is in a great spot!

CHANGELOG.md Outdated Show resolved Hide resolved
src-docs/src/views/expression/columns.js Outdated Show resolved Hide resolved
src-docs/src/views/expression/columns.js Outdated Show resolved Hide resolved
src-docs/src/views/expression/columns.js Outdated Show resolved Hide resolved
src-docs/src/views/expression/expression_example.js Outdated Show resolved Hide resolved
src/components/expression/expression.tsx Outdated Show resolved Hide resolved
src/components/expression/expression.tsx Outdated Show resolved Hide resolved
src/components/expression/expression.tsx Outdated Show resolved Hide resolved
src/components/expression/expression.tsx Outdated Show resolved Hide resolved
src/components/expression/_expression.scss Outdated Show resolved Hide resolved
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

Copy link
Contributor

@mdefazio mdefazio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Nice work!

@andreadelrio andreadelrio requested a review from cchaos June 2, 2020 04:52
@cchaos cchaos requested a review from thompsongl June 2, 2020 14:47
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 LGTM! Just a few nit comments now. I also added Greg for an eng for review.

const [example1, setExample1] = useState({
isOpen: false,
value: (
<div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this div, but if you do, it gets removed if you change the selected options, so you need to add it to the onChange function as well. You can simply change it to a fragment <></>

Comment on lines 54 to 56
setExample2({
...example2,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setExample2({
...example2,
});

Comment on lines 67 to 69
setExample1({
...example1,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setExample1({
...example1,
});

text: (
<p>
To truncate <strong>EuiExpression</strong>&apos;s content, pass{' '}
<EuiCode>truncate</EuiCode> to the <EuiCode>textWrap</EuiCode> prop.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<EuiCode>truncate</EuiCode> to the <EuiCode>textWrap</EuiCode> prop.
<EuiCode language="ts">{'textWrap="truncate"'}</EuiCode>.

Text truncation only works properly if the prop types of{' '}
<EuiCode>description</EuiCode> and <EuiCode>value</EuiCode> are
strings. If you&apos;re using nodes, use the{' '}
<EuiCode>.eui-textTruncate</EuiCode>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<EuiCode>.eui-textTruncate</EuiCode>
<EuiCode>.eui-textTruncate</EuiCode>{' '}

Comment on lines 8 to 11
<div>
<p className="eui-textTruncate">.kibana_task_manager</p>
<p className="eui-textTruncate">kibana_sample_data_ecommerce</p>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div>
<p className="eui-textTruncate">.kibana_task_manager</p>
<p className="eui-textTruncate">kibana_sample_data_ecommerce</p>
</div>
<>
<p className="eui-textTruncate">.kibana_task_manager</p>
<p className="eui-textTruncate">kibana_sample_data_ecommerce</p>
</>

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM 👍

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3467/

@andreadelrio andreadelrio merged commit 7b00314 into elastic:master Jun 2, 2020
daveyholler pushed a commit to daveyholler/eui that referenced this pull request Jun 3, 2020
…ression (elastic#3467)

* added prop

* added test and updated example

* add cl

* added description to tooltip

* renamed prop, turned into enum

* example is function component

* update snippet

* make the example more like alerting

* new styles

* basic combobox working

* more progress on example

* added align right

* removed truncate

* renamed column prop

* cleanup

* updated tests and added handling of color

* remove unneeded line

* Review updates

* update test

* re-added textWrap prop

* update cl

* PR feedback

Co-authored-by: cchaos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants